package com.net;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;


import android.content.Context;
import android.os.Handler;

import com.utils.Const;



public class HttpRequestControll {

	
	 private static final ThreadPoolExecutor mThreadPoolExecutor = (ThreadPoolExecutor) Executors
	            .newCachedThreadPool();
	 private static Handler mHandler = null;
	    
	 private static void checkHandler() {
	        try {
	            if (mHandler == null) {
	                mHandler = new Handler();
	            }
	        } catch (Exception e) {
	            mHandler = null;
	        }
	    }
	
	/**
	 * 登录
	 * @param param
	 * @param callBack
	 */
	public static void httpLogin(final Context context,final String loginName,final String pwd,final HttpRequestUtil.HttpRonspontCallBack callBack){
		try {
			

			checkHandler();
    		mThreadPoolExecutor.execute(new Runnable() {
    			
    			@Override
    			public void run() {
    				try {
    					
    					
    					HttpRequest param = new HttpRequest();
    					//param.methorid = Const.APP_URL;
    					param.params.add(new RequestParam("key", "value"));
    					
    					final HttpResponse result = new HttpRequestUtil(param, HttpRequestUtil.HTTP_POST, callBack).contentWebservice();

    					mHandler.post(new Runnable() {
							
							@Override
							public void run() {
								callBack.callBack(result);			
							}
						});
					} catch (Exception e) {
						e.printStackTrace();
					}
    				
    			}
    		});
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
}
